const order = [
  {
    id: 1,
    orderNo: 'ORD2024001',
    customerName: '张三',
    productName: '预制菜套餐A',
    quantity: 2,
    totalPrice: 199.98,
    status: 'pending',
    createTime: '2024-01-01T10:00:00Z',
    address: '北京市朝阳区xxx街道xxx号',
    phone: '13800138000',
  },
  {
    id: 2,
    orderNo: 'ORD2024002',
    customerName: '李四',
    productName: '预制菜套餐B',
    quantity: 1,
    totalPrice: 99.99,
    status: 'processing',
    createTime: '2024-01-02T11:00:00Z',
    address: '上海市浦东新区xxx路xxx号',
    phone: '13900139000',
  },
  {
    id: 3,
    orderNo: 'ORD2024003',
    customerName: '王五',
    productName: '预制菜套餐C',
    quantity: 3,
    totalPrice: 299.97,
    status: 'completed',
    createTime: '2024-01-03T12:00:00Z',
    address: '广州市天河区xxx路xxx号',
    phone: '13700137000',
  },
  {
    id: 4,
    orderNo: 'ORD2024004',
    customerName: '赵六',
    productName: '预制菜套餐D',
    quantity: 1,
    totalPrice: 149.99,
    status: 'cancelled',
    createTime: '2024-01-04T13:00:00Z',
    address: '深圳市南山区xxx路xxx号',
    phone: '13600136000',
  },
];

export default {
  'GET /api/order': (req: any, res: any) => {
    res.json({
      success: true,
      data: { order },
      total: order.length,
      errorCode: 0,
    });
  },
  'POST /api/order/add': (req: any, res: any) => {
    order.push({ id: order.length + 1, ...req.body });
    res.send({
      code: 200,
      success: true,
      message: '成功',
      data: req.body,
    });
  },
  'POST /api/order/update': (req: any, res: any) => {
    const index = order.findIndex((item) => item.id === req.body.id);
    if (index !== -1) {
      order[index] = req.body;
    }
    res.send({
      code: 200,
      success: true,
      message: '成功',
      data: req.body,
    });
  },
  'POST /api/order/delete': (req: any, res: any) => {
    const index = order.findIndex((item) => item.id === req.body.id);
    if (index !== -1) {
      order.splice(index, 1);
    }
    res.json({
      success: true,
      data: req.body.id,
    });
  },
}; 